# @Author: slp
# @Date:   2018-07-05 16:36:14
# @Last Modified by:   ystlong
# @Last Modified time: 2018-07-21 03:08:04

get_script_real_file()
{
  real_entry_dir=`pwd`
  script_real_file=$BASH_SOURCE
  i=0
  while [[ `ls -l $script_real_file|grep -e '->'` != "" ]]; do
    # get link file
    link_script_real_file=`ls $script_real_file -l|awk -F '->' '{print $2}'`
    # delete blank char
    link_script_real_file=`echo $link_script_real_file`
    # check link symbol file abs path or relative path
    cg_link_script_real_file=`dirname $script_real_file`/$link_script_real_file
    if [ ! -e $cg_link_script_real_file ]; then
      #  link symbol use abs path
      cg_link_script_real_file=$link_script_real_file
    fi
    script_real_file=$cg_link_script_real_file
    echo "find-link-file: $cg_link_script_real_file"
    i=$((i+1))
    if [[ $i -gt 10 ]]; then
      echo "can not find the sublime start cmd, maybe much symbol link"
      exit 1
    fi
  done
  script_real_dir=`dirname $script_real_file`
  script_abs_real_dir=`cd $script_real_dir&&pwd`
  cd $real_entry_dir
}
get_script_real_file

SOFT_ROOT=$script_abs_real_dir

if [ x$1 = x ]; then
	echo "usage: $0 elf_path"
	exit 1
fi
rm -f trace.tarmac


Foundation_Platform --image=$1 --cores=1

